<!-- <template>
    <div class="header-top-fixed">
        <div class="container">
            <div class="left_">
                <a href="">
                    <img src="../../assets/logo.png" alt="logo">
                </a>
            </div>
            <div class="right_">
                <ul>
                    <li>
                        <router-link to="/">首页</router-link>
                        <span></span>
                    </li>
                    <li>
                        <router-link to="/about">院部简介</router-link>
                    </li>
                    <li>
                        <router-link to="index">办学特殊</router-link>
                    </li>
                    <li>
                        <router-link to="index">专业简介</router-link>
                    </li>
                    <li>
                        <router-link to="index">领导关怀</router-link>
                    </li>
                    <li>
                        <router-link to="index">对外交流</router-link>
                    </li>
                    <li>
                        <router-link to="index">社会服务</router-link>
                    </li>
                    <li>
                        <router-link to="index">师资力量</router-link>
                    </li>
                    <li>
                        <router-link to="index">实训中心</router-link>
                    </li>
                    <li>
                        <router-link to="index">实习基地</router-link>
                    </li>
                </ul>
            </div>
            <button class="header-button" @click="toggleYCVisible">
                <span>一</span>
                <span>一</span>
                <span>一</span>
            </button>
            <div class="yc" v-if="isYCVisible">
                <ul>
                    <li><router-link to="/">首页</router-link></li>
                    <li><router-link to="index">院部简介</router-link></li>
                    <li><router-link to="index">办学特殊</router-link></li>
                    <li><router-link to="index">专业简介</router-link></li>
                    <li><router-link to="index">领导关怀</router-link></li>
                    <li><router-link to="index">对外交流</router-link></li>
                    <li><router-link to="index">社会服务</router-link></li>
                    <li><router-link to="index">师资力量</router-link></li>
                    <li><router-link to="index">实训中心</router-link></li>
                    <li><router-link to="index">实习基地</router-link></li>
                </ul>
            </div>
        </div>

    </div>
</template>

<script setup>
import { ref } from 'vue';

// 控制制制yc的显示状态
const isYCVisible = ref(false);

// 切制显示与隐藏的函数
const toggleVisible = () => {
    isYCVisible.value = !isYCVisible.value;
};
</script> -->

<template>
    <div class="header-top-fixed">
      <div class="container">
        <div class="left_">
                <a href="">
                    <img src="../../assets/logo.png" alt="logo">
                </a>
        </div>
        <div class="right_">
          <ul>
            <li v-for="(item, index) in menuItems" :key="index">
              <router-link :to="item.path">{{ item.name }}</router-link>
            </li>
          </ul>
        </div>
        <!-- 点击button将.yc设置为display: block -->
        <button class="header-button" @click="toggleYCVisible">
          <span>一</span>
          <span>一</span>
          <span>一</span>
        </button>
        <div class="yc" v-if="ycVisible">
          <ul>
            <li v-for="(item, index) in menuItems" :key="index">
              <router-link :to="item.path">{{ item.name }}</router-link>
            </li>
          </ul>
        </div>
        <!-- 修改部分结束 -->
      </div>
    </div>
  </template>
  
  <script setup>
  import { ref } from 'vue';
  
  const ycVisible = ref(false); // 初始状态为隐藏

const toggleYCVisible = () => {
    console.log(ycVisible.value);
  ycVisible.value = !ycVisible.value;
  console.log(ycVisible.value);
};
  // 菜单项数据
  const menuItems = [
    { name: '首页', path: '/' },
    { name: '院部简介', path: '/about' },
    { name: '办学特殊', path: '' },
    { name: '专业简介', path: '' },
    { name: '领导关怀', path: '' },
    { name: '对外交流', path: '' },
    { name: '社会服务', path: '' },
    { name: '师资力量', path: '' },
    { name: '实训中心', path: '' },
    { name: '实习基地', path: '' },
  ];
  
  </script>

<style scoped lang="scss">
.header-top-fixed {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    background: linear-gradient(to right, #660103 0%, #9a0a06 50%, #660103 100%);

    @media (max-width: 468px) {
        position: static;
    }

    .container {
        width: 80%;
        height: 100%;
        margin: 0 auto;
        display: flex;
        justify-content: space-between;

        .left_ {
            width: 12%;
            height: 100%;

            @media (max-width: 468px) {
                width: 50%;
            }

            img {
                width: 100%;
                height: 100%;
            }
        }

        .right_ {
            @media (max-width: 468px) {
                display: none;
            }

            width: 80%;
            height: 100%;

            ul {
                position: relative;
                display: flex;
                justify-content: space-between;
                width: 100%;
                height: 100%;

                li {
                    flex: 1;
                    text-align: center;
                    height: 100%;
                    font-weight: 600;
                    font-size: 14px;

                    a {
                        display: block;
                        width: 100%;
                        height: 100%;
                        line-height: 50px;
                    }

                    span {
                        position: absolute;
                        display: block;
                        top: 40px;
                        left: 38px;
                        z-index: 11;
                        width: 30px;
                        height: 2px;
                        background-color: #005bac;
                    }
                }
            }
        }

        .header-button {
            display: none;

            @media (max-width: 475px) {
                display: block;
                width: 8%;
                height: 100%;
                text-align: center;
                border: none;
                outline: none;
                background: transparent;
                color: #000;
                position: absolute;
                z-index: 11;
                right: 10px;
                top: 0px;
            }

            span {
                position: absolute;
                display: block;
                width: 20px;
                height: 2px;
                color: #fff;
                z-index: 1;

                &:nth-child(1) {
                    width: 30px;
                    top: 6px;
                }

                &:nth-child(2) {
                    width: 30px;
                    top: 10px;
                }

                &:nth-child(3) {
                    width: 30px;
                    top: 14px;
                }
            }
        }

        .yc {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            z-index: 9;
            background-color: rgba($color: #000, $alpha: 0.5);

            ul {
                padding: 60px 0;
                display: flex;
                flex-wrap: wrap;
                width: 100%;

                li {
                    margin: 0 auto;
                    width: 84%;
                    height: 40px;

                    a {
                        display: block;
                        width: 100%;
                        color: #fff;
                    }
                }
            }
        }

        .show {
            display: block;
        }
    }
}
</style>